﻿<local:ItemWithImages x:Class="WpfApp1.Views.Products.Reviews.ProductsReviewsItemWithImages"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WpfApp1.Views"
        mc:Ignorable="d"
        ResizeMode="NoResize"
        Icon="\Resources\wb.ico"
        Title="ItemForm" Height="588" Width="458">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="205"/>
            <RowDefinition />
            <RowDefinition Height="41" />
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="140"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>

            <Label Grid.Column="0" Grid.Row="0" Content="Id заказа" VerticalAlignment="Center"/>
            <TextBox x:Name="tbId" 
                     Width="280"
                     Grid.Column="1"
                     Grid.Row="0"
                     HorizontalAlignment="Left"
                     Margin="0 5" 
                     Text="{Binding CurrentItem.OrderId, UpdateSourceTrigger=PropertyChanged}"
                     Style="{StaticResource CommonTextBox}" />

            <Label Grid.Column="0" Grid.Row="1" Content="Товар" VerticalAlignment="Center"/>
            <ComboBox x:Name="cbProduct"
                      Grid.Row="1"
                      Grid.Column="1" 
                      Style="{StaticResource CommonComboBox}"
                      Width="280" 
                      ItemsSource="{Binding Products}"
                      HorizontalAlignment="Left"
                      IsEnabled="False"
                      SelectedValue="{Binding CurrentItem.Order.Product}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Label Content="{Binding Id}"/>
                            <Label Content="{Binding Title}"/>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>

            <Label Grid.Column="0" Grid.Row="2" Content="Пользователь" VerticalAlignment="Center"/>
            <ComboBox x:Name="cbUser"
                      Grid.Row="2"
                      Grid.Column="1" 
                      Style="{StaticResource CommonComboBox}"
                      Width="280" 
                      ItemsSource="{Binding Users}"
                      HorizontalAlignment="Left"
                      IsEnabled="False"
                      SelectedValue="{Binding CurrentItem.Order.User}">
                <ComboBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Label Content="{Binding Id}"/>
                            <Label Content="{Binding Lastname}"/>
                            <Label Content="{Binding Firstname}"/>
                            <Label Content="{Binding Patronymic}"/>
                        </StackPanel>
                    </DataTemplate>
                </ComboBox.ItemTemplate>
            </ComboBox>
            
            <Label Grid.Column="0" Grid.Row="3" Content="Отзыв"  VerticalAlignment="Center"/>
            <TextBox x:Name="tbReview" 
                     Width="280"
                     Grid.Column="1"
                     Grid.Row="3"
                     HorizontalAlignment="Left"
                     Margin="0 5" 
                     Text="{Binding CurrentItem.ReviewText, UpdateSourceTrigger=PropertyChanged}" 
                     Style="{StaticResource CommonTextBox}" />

            <TextBlock Margin="5 0" Grid.Column="0" Grid.Row="4" Text="Оценка" TextWrapping="Wrap" VerticalAlignment="Center"/>
            <TextBox x:Name="tbStars" 
                     Width="280"
                     Grid.Column="1"
                     Grid.Row="4"
                     HorizontalAlignment="Left"
                     Margin="0 5" 
                     Text="{Binding CurrentItem.Stars, UpdateSourceTrigger=PropertyChanged}" 
                     Style="{StaticResource CommonTextBox}" />
        </Grid>

        <Grid Grid.Row="1" Margin="10 10 10 5">
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="41"/>
            </Grid.RowDefinitions>
            <ListBox x:Name="lbImages" Grid.Row="0" PreviewMouseDoubleClick="lbImages_PreviewMouseDoubleClick">
                <ListBox.ItemTemplate>
                    <DataTemplate>
                        <Image Width="100" Height="100" Source="{Binding Image}"/>
                    </DataTemplate>
                </ListBox.ItemTemplate>
            </ListBox>
            <Button x:Name="btnAddImage" HorizontalAlignment="Right" Margin="10 5" Width="110" Grid.Row="1" Template="{StaticResource commonButton}" Command="{Binding InsertImageCommand}">Добавить</Button>
        </Grid>

        <DockPanel Grid.Row="2">
            <Button x:Name="btnDataAction" Margin="20 5" Width="110" HorizontalAlignment="Left" Template="{StaticResource commonButton}" Command="{Binding SaveCommand}">Сохранить</Button>
            <Button x:Name="btnClose" Margin="20 5" Width="110" HorizontalAlignment="Right" Template="{StaticResource commonButton}" Click="btnClose_Click">Закрыть</Button>
        </DockPanel>
    </Grid>
</local:ItemWithImages>